<template>
  <MainLayout title="页面标题">
    <view class="p-12">
      <view class="card">用户：{{ user?.username }}</view>
      <button @click="syncPeople">同步人员信息</button>
      <button @click="toLogs">操作日志</button>
      <button type="warn" @click="logout">退出登录</button>
    </view>
  </MainLayout>

</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { api } from '@/services/api'
import MainLayout from '@/layouts/MainLayout.vue'
const user = ref<any>(null)
onMounted(async()=>{ user.value = await api.me() })
async function syncPeople(){ await api.syncPeople(); uni.showToast({ title:'已触发同步' }) }
function toLogs(){ uni.navigateTo({ url:'/pages/records/index' }) }
function logout(){ uni.clearStorageSync(); uni.reLaunch({ url:'/pages/login/login' }) }
</script>

<style scoped>.p-12{padding:12px}.card{background:#fff;border-radius:8px;padding:12px;margin-bottom:12px}</style>
